require 'socket'

socket = Socket.new(:INET,:STREAM)

remote_addr = Socket.pack_sockaddr_in(7000,'www.cc.com')

socket.connect(remote_addr)

# 不存在的地址或端口，链接超时
# /home/zd/.rvm/rubies/ruby-2.4.1/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /home/zd/zd04/tcpSockets/snippets/connet_non_existent.rb
# /home/zd/zd04/tcpSockets/snippets/connet_non_existent.rb:7:in `connect': Connection timed out - connect(2) for 23.209.176.237:7000 (Errno::ETIMEDOUT)
# 	from /home/zd/zd04/tcpSockets/snippets/connet_non_existent.rb:7:in `<top (required)>'
# 	from -e:1:in `load'
# from -e:1:in `<main>'
#
# Process finished with exit code 1